<!DOCTYPE html>
<?php session_star();?>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>商品</title>
    <script src="../js/jquery.min.js"></script>
    <!-- 引入bootstarp -->
    <script  src="../js/bootstrap3/js/bootstrap.js"></script>
    <link rel="stylesheet" href="../js/bootstrap3/css/bootstrap.css">
    <!-- 引入tree的js、css -->
    <script src="../js/bootstrap-treeview/bootstrap-treeview.min.js"></script>
    <link rel="stylesheet" href="../js/bootstrap-treeview/bootstrap-treeview.min.css">
    <!-- 引入选项卡的js、css -->
    <script src="../js/bootStrap-addTabs/bootstrap.addtabs.js"></script>
    <link rel="stylesheet" href="../js/bootStrap-addTabs/bootstrap.addtabs.css">
</head>
<body>
<div class="panel panel-default">
    <div class="panel-heading">
        <h5>
            欢迎:<button type="button" class="btn btn-link" onclick="login()"><span id="span">登录</span></button>
            <span style="float: right;">
               <font color="#a52a2a" size="5px"> 卖家服务 </font>
            </span>
        </h5>
    </div>
    <div class="container-fluid">
        <div class="col-md-3">
            <div id="productTree"></div>
        </div>
        <div class="col-md-9">
            <div id="myTabs">
                <!-- 新选项卡 -->
                <ul class="nav nav-tabs" id="tablist">
                    <li role="presentation" class="active">
                        <a href="#home" role="tab" data-toggle="tab">欢迎</a>
                    </li>
                </ul>
                <!-- 选项卡下内容 -->
                <div class="tab-content">
                    <div role="tabpanel" class="tab-pane active" id="home"></div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    //初始化导航树
    $(function(){
        initProductTree();
        checkLogin();
    })

    //获取登录账号
    function checkLogin(){
        $.ajax({
            url:"../product/checkLogin",
            data:{},
            type:"post",
            dataType:"json",
            success:function(data){
                if (data.code==2){
                    $("#span").text(data.userName);
                }
            }
        })
    }

    //导航树
    function initProductTree(){
        $.post('../product/findProductTree',{},function(data){
            $("#productTree").treeview({
                data:data,
                onNodeSelected:function(even,node){
                    $.addtabs.add({
                        id:node.id,
                        title:node.text,
                        url:node.href
                    })
                }
            })
        })
    }

   function login(){
        location.href="../page/toLogin";
   }
</script>
</html>